package io.renren.modules.simida.controller;

import java.util.Arrays;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.simida.entity.UserInfoEntity;
import io.renren.modules.simida.service.UserInfoService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 用户信息表
 *
 * @author miaoguoxin
 * @email ${email}
 * @date 2019-11-17 09:57:32
 */
@RestController
@RequestMapping("simida/userinfo")
public class UserInfoController {
    @Autowired
    private UserInfoService userInfoService;

    /**
     * 列表
     */
    @GetMapping("/list")
    @RequiresPermissions("simida:userinfo:list")
    public R list(@RequestParam Map<String,Object> params){
        PageUtils page = userInfoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{userId}")
    @RequiresPermissions("simida:userinfo:info")
    public R info(@PathVariable("userId") Long userId){
        return R.ok().put("userInfo", userInfoService.queryUserInfo(userId));
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("simida:userinfo:save")
    public R save(@RequestBody UserInfoEntity userInfo){
		userInfoService.save(userInfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("simida:userinfo:update")
    public R update(@RequestBody UserInfoEntity userInfo){
		userInfoService.updateById(userInfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("simida:userinfo:delete")
    public R delete(@RequestBody Long[] userIds){
		userInfoService.removeByIds(Arrays.asList(userIds));

        return R.ok();
    }

}
